from flask_admin.form import FileUploadField
from wtforms import validators

from ..constants import messages_media_folder
from .base import MyBaseModelView


class CheckMessageModelView(MyBaseModelView):
    column_list = ("text_ru", "calendars")

    form_excluded_columns = ("created_at", "updated_at")

    column_labels = {
        "text_ru": "Текст сообщения (ru)",
        "text_en": "Текст сообщения (en)",
        "text_uk": "Текст сообщения (ua)",
        "calendars": "Календари",
        "media_filename": "Фото / видео",
    }

    form_extra_fields = {
        "media_filename": FileUploadField(
            label="Фото / видео (максимум 10 мб)",
            validators=[validators.DataRequired()],
            base_path=messages_media_folder,
            allow_overwrite=True,
            allowed_extensions=["png", "jpg", "jpeg", "mp4"],
        )
    }
